Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable std::filesystem on macOS when compiling C++17 but targetting <10.15 #335

Merged

Conversation

jagerman
Copy link
Contributor

macOS flat out refuses to compile if you touch std::filesystem::path when targetting macOS < 10.15 (to be able to deploy a binary to older macOS versions) with the -mmacosx-version-min=10.14 (or earlier) compiler flags.

If you try to compile code with ::path (even if you don't actually call it) the Apple clang gods smite you with:

foo.cpp:8:26: error: 'path' is unavailable: introduced in macOS 10.15
        std::filesystem::path p;
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/filesystem:738:24: note: 'path' has been explicitly marked unavailable here
class _LIBCPP_TYPE_VIS path {
                       ^

This is reportedly caused by Apple's C++ team being somewhat incompetent at actually updating libc++ when they push out new releases, so libc++ stl features (in this case, to get at the std::filesystem exceptions from libc++) often lag behind the compiler by years, and Apple never releases libc++ updates for older mac versions because they don't care because C++ isn't Swift and only Swift is great and good.

</rant>

Anyway, this PR works around the issue by disabling the std::filesystem::path support when in C++17 mode when targetting macOS before 10.15.

I also broke up the hairy macro conditions because it was already hard to follow and would have gotten worse if kept in a single condition.

macOS flat out refuses to compile if you touch std::filesystem when
targetting macOS < 10.15 (to be able to deploy a binary to older macOS
versions).

This disables the std::filesystem support when in C++17 mode with such a
target.
@paulocoutinhox
Copy link
Contributor

Please, can you check and merge?

@SRombauts SRombauts merged commit 4939c32 into SRombauts:master Oct 2, 2021
@SRombauts
Copy link
Owner

Yes, nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants